/**
 * @author brianxia
 * @version 1.0
 * @date 2021/10/7 18:56
 */
public class DeadLock {
    public static void main(String[] args) {
        Object o1 = new Object();
        Object o2 = new Object();
        Thread thread1 = new Thread(() -> {
            synchronized (o1){
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (o2){

                }
            }
        });
        Thread thread2 = new Thread(() -> {
            synchronized (o1){
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (o2){

                }
            }
        });
        thread1.start();
        thread2.start();
    }
}
